package com.lfs.admin.util;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.lfs.base.util.CollectionUtils;
import com.lfs.base.util.HttpClientUtil;
import com.lfs.base.util.MD5Utils;
import com.lfs.dto.entity.UserInfoEntity;
import com.lfs.http.httpclient.HttpClientGet;
import com.lfs.http.httpclient.HttpClientPost;
import com.lfs.http.httpclient.OkHttpUtil;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import org.apache.catalina.User;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import sun.misc.BASE64Encoder;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.*;

public class Test {
    public static void main(String[] args) {
        arrayIndexOutOfBounds();
    }

    public static String getHttpEntityContent(HttpResponse response) throws UnsupportedOperationException, IOException{
        String result = "";
        HttpEntity entity = response.getEntity();
        if(entity != null){
            InputStream in = entity.getContent();
            BufferedReader br = new BufferedReader(new InputStreamReader(in, "utf-8"));
            StringBuilder strber= new StringBuilder();
            String line = null;
            while((line = br.readLine())!=null){
                strber.append(line+'\n');
            }
            br.close();
            in.close();
            result = strber.toString();
        }

        return result;

    }


    public static void arrayIndexOutOfBounds(){
        try {

            // TODO 自动生成的方法存根
            LinkedList<UserInfoEntity> li = new LinkedList();
            li.getFirst();

            li.add(new UserInfoEntity());
            li.add(new UserInfoEntity());
            li.add(new UserInfoEntity());

            ListIterator it = li.listIterator();//获取列表迭代器
            while (it.hasNext()) {
                Object obj = it.next();
                System.out.println(it.next()); //**********
            }


        } catch (NoSuchElementException e){
            System.out.println("数组访问越界,请检查!");
            e.printStackTrace();
        }finally {
            System.out.println("程序结束!");
        }
    }
}
